﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Data;
namespace DAL
{
    class DoSQL
    {

        public MySqlConnection mysql;

        public DoSQL()
        {
            initmysql();
            openmysql();
        }

        public void initmysql()
        {
            string connstr = "Database=blog;Data Source = 127.0.0.1;User Id=root;password=cll19900714;port=3306;charset=utf8";
           // string connstr = "Database=blog;Data Source = 192.168.23.129;User Id=root;password=cll19900714;port=3306;charset=utf8";
            mysql = new MySqlConnection(connstr);
            mysql.Open();
        }

        public void openmysql()
        {
            if (mysql.State == ConnectionState.Closed)
            {
                mysql.Open();
            }
            // return mysql;
        }

        public void closemysql()
        {
            if (mysql.State == ConnectionState.Open)
            {
                mysql.Close();
            }
        }

    }
}
